﻿@using Mulala.Cavan.Domain.MainBoundedContext.ConsignModule
@model Mulala.Cavan.Presentation.Mvc.ViewModel.INannyBiddingConsignViewModel
@{
    ViewBag.Title = "竞标委托";
    Layout = "~/Views/Shared/_NannyCenterLayout.cshtml";
}
@section header{
    <title>@ViewBag.Title</title>
}
@{
    var cancelID = string.Empty;
    var resumeID = string.Empty;
    var consignID = string.Empty;
    var index = 1;
}
@foreach (IConsignBidderViewModel cb in @Model.ConsignBidders)
{
    cancelID = "cancel" + index.ToString();
    resumeID = "resume" + index.ToString();
    consignID = "consignID" + index.ToString();
    <p>@cb.Item.Bidder.Name</p>
    <p>@cb.Item.Consign.Name</p>
    <p>@cb.Status</p> 
    if (cb.Status == "撤销")
    { 
         <input type="button" value="恢复" id="@resumeID"/>
        <input type="button" value="撤销" id="@cancelID" style="display:none"/>
    }
    else
    { 
        <input type="button" value="撤销" id="@cancelID"/>
        <input type="button" value="恢复" id="@resumeID" style="display:none"/>
    }
    <input type="hidden" value="@cb.Item.Consign.ID" id="@consignID" />
    index = index + 1;
}
@{
    Html.RenderAction("recommendconsign", "Consign");
}
@{
    Html.RenderAction("popularproprietor", "Proprietor");
}
<script type="text/javascript">
    $(function () {
        $(":button").bind("click", function () {
            var index = $(this).attr("id").substring(6);
            var consignID = $("#consignID" + index).val();
            if ($(this).val() == "撤销") {
                $.ajax({
                    url: '/nannycenter/unbidconsign/' + consignID,
                    type: 'POST',
                    success: function (data) {
                        if (data) {
                            if (data.IsSuccess) {
                                $("#cancel" + index).hide();
                                $("#resume" + index).show();
                            }
                        }
                    },
                    error: function () {
                    }
                })
            }
            else {
                $.ajax({
                    url: '/nannycenter/resumebidconsign/' + consignID,
                    type: 'POST',
                    success: function (data) {
                        if (data) {
                            if (data.IsSuccess) {
                                $("#cancel" + index).show();
                                $("#resume" + index).hide();
                            }
                        }
                    },
                    error: function () {
                    }
                })
            }
        });
    })
</script>
